home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWBag.z / RWBag
Encoding:
Text File  |  1998-10-30  |  11.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))                                                        RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWBag - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               typedef RWBag Bag;     // Smalltalk typedef .
  13.  
  14.  
  15.  
  16.               #include <rw/rwbag.h>
  17.           RWBag h;
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWBBBBaaaagggg corresponds to the Smalltalk class BBBBaaaagggg.  It represents a
  24.      group of unordered elements, not accessible by an external key.
  25.      Duplicates are allowed. An object stored by RRRRWWWWBBBBaaaagggg must inherit abstract
  26.      base class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee, with suitable definition for virtual functions
  27.      hhhhaaaasssshhhh(((()))) and iiiissssEEEEqqqquuuuaaaallll(((()))) (see class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee).  The function hhhhaaaasssshhhh(((()))) is
  28.      used to find objects with the same hash value, then iiiissssEEEEqqqquuuuaaaallll(((()))) is used to
  29.      confirm the match. Class RRRRWWWWBBBBaaaagggg is implemented by using an internal hashed
  30.      dictionary (RRRRWWWWHHHHaaaasssshhhhDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy) which keeps track of the number of
  31.      occurrences of an item.  If an item is added to the collection that
  32.      compares equal (iiiissssEEEEqqqquuuuaaaallll) to an existing item in the collection, then the
  33.      count is incremented.  Note that this means that only the first instance
  34.      of a value is actually inserted: subsequent instances cause the
  35.      occurrence count to be incremented.  This behavior parallels the
  36.      Smalltalk implementation of BBBBaaaagggg.  Member function aaaappppppppllllyyyy(((()))) and the
  37.      iterator are called repeatedly according to the count for an item.  See
  38.      class RRRRWWWWHHHHaaaasssshhhhTTTTaaaabbbblllleeee if you want duplicates to be stored, rather than merely
  39.      counted.
  40.  
  41. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  42.      Polymorphic
  43.  
  44. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  45.               RWBag(size_t n = RWDEFAULT_CAPACITY);
  46.  
  47.  
  48.      Construct an empty bag with nnnn buckets.
  49.  
  50.               RWBag(const RWBag& b);
  51.  
  52.  
  53.      Copy constructor.  A shallow copy of bbbb will be made.
  54.  
  55. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  56.               void
  57.           ooooppppeeeerrrraaaattttoooorrrr====(const RWBag& b);
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))                                                        RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      Assignment operator.  A shallow copy of bbbb will be made.
  75.  
  76.               RWBoolean
  77.           ooooppppeeeerrrraaaattttoooorrrr========(const RWBag& b) const;
  78.  
  79.  
  80.      Returns TTTTRRRRUUUUEEEE if self and bag bbbb have the same number of total entries and
  81.      if for every key in self there is a corresponding key in bbbb which iiiissssEEEEqqqquuuuaaaallll
  82.      and which has the same number of entries.
  83.  
  84. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  85.               virtual void
  86.           aaaappppppppllllyyyy(RWapplyCollectable ap, void*);
  87.  
  88.  
  89.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  This function has been redefined to
  90.      apply the user-supplied function pointed to by aaaapppp to each member of the
  91.      collection in a generally unpredictable order.  If an item has been
  92.      inserted more than once (iiii....eeee...., more than one item iiiissssEEEEqqqquuuuaaaallll), then aaaappppppppllllyyyy(((())))
  93.      will be called that many times.  The user-supplied function should not do
  94.      anything that could change the hash value or the meaning of "iiiissssEEEEqqqquuuuaaaallll" of
  95.      the items.
  96.  
  97.               virtual RWspace
  98.           bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const;
  99.  
  100.  
  101.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  102.  
  103.               virtual void
  104.           cccclllleeeeaaaarrrr();
  105.  
  106.  
  107.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  108.  
  109.               virtual void
  110.           cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy();
  111.  
  112.  
  113.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  114.  
  115.               virtual int
  116.           ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable* a) const;
  117.  
  118.  
  119.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  120.  
  121.               virtual RWBoolean
  122.           ccccoooonnnnttttaaaaiiiinnnnssss(const RWCollectable* target) const;
  123.  
  124.  
  125.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))                                                        RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual size_t
  141.           eeeennnnttttrrrriiiieeeessss() const;
  142.  
  143.  
  144.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  145.  
  146.               virtual RWCollectable*
  147.           ffffiiiinnnndddd(const RWCollectable* target) const;
  148.  
  149.  
  150.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  The first item that was inserted into
  151.      the BBBBaaaagggg and which equals ttttaaaarrrrggggeeeetttt is returned or nnnniiiillll if no item is found.
  152.      Hashing is used to narrow the search.
  153.  
  154.               virtual unsigned
  155.           hhhhaaaasssshhhh() const;
  156.  
  157.  
  158.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  159.  
  160.               virtual RWCollectable*
  161.           iiiinnnnsssseeeerrrrtttt(RWCollectable* c);
  162.  
  163.  
  164.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  Inserts the item cccc into the
  165.      collection and returns it, or if an item was already in the collection
  166.      that iiiissssEEEEqqqquuuuaaaallll to cccc, then returns the old item and increments its count.
  167.  
  168.               RWCollectable*
  169.           iiiinnnnsssseeeerrrrttttWWWWiiiitttthhhhOOOOccccccccuuuurrrrrrrreeeennnncccceeeessss(RWCollectable* c,size_t n);
  170.  
  171.  
  172.      Inserts the item cccc into the collection with count nnnn and returns it, or if
  173.      an item was already in the collection that iiiissssEEEEqqqquuuuaaaallll to cccc, then returns the
  174.      old item and increments its count by nnnn.
  175.  
  176.               virtual RWClassID
  177.           iiiissssAAAA() const;
  178.  
  179.  
  180.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee to return ________RRRRWWWWBBBBAAAAGGGG.
  181.  
  182.               virtual RWBoolean
  183.           iiiissssEEEEmmmmppppttttyyyy() const;
  184.  
  185.  
  186.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  187.  
  188.               virtual RWBoolean
  189.           iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* a) const;
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))                                                        RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  207.  
  208.               virtual size_t
  209.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const RWCollectable* target) const;
  210.  
  211.  
  212.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  Returns the number of items that aaaarrrreeee
  213.      eeeeqqqquuuuaaaallll ttttoooo the item pointed to by ttttaaaarrrrggggeeeetttt.
  214.  
  215.               virtual RWCollectable*
  216.           rrrreeeemmmmoooovvvveeee(const RWCollectable* target);
  217.  
  218.  
  219.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  Removes and returns the item that
  220.      iiiissssEEEEqqqquuuuaaaallll to the item pointed to by ttttaaaarrrrggggeeeetttt.  Returns nnnniiiillll if no item was
  221.      found.
  222.  
  223.               virtual void
  224.           rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(const RWCollectable* target);
  225.  
  226.  
  227.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.  Removes the item that iiiissssEEEEqqqquuuuaaaallll to the
  228.      item pointed to by ttttaaaarrrrggggeeeetttt.  Destroys the item as well if it is the last
  229.      occurrence in the collection.
  230.  
  231.               void
  232.           rrrreeeessssiiiizzzzeeee(size_t n = 0);
  233.  
  234.  
  235.      Resizes the internal hash table to have nnnn buckets.  The overhead for this
  236.      function is the hashing of every element in the collection.  If nnnn is
  237.      zero, then an appropriate size will be picked automatically.
  238.  
  239.               virtual void
  240.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&);
  241.           virtual void
  242.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&);
  243.           virtual void
  244.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&) const;
  245.           virtual void
  246.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&) const;
  247.  
  248.  
  249.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn.
  250.  
  251.               RWStringID
  252.           ssssttttrrrriiiinnnnggggIIIIDDDD();
  253.  
  254.  
  255.      (acts virtual) Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.